/*
 * @Description: 
 * @Author: HKH
 * @Date: 2024-09-13 10:37:17
 * @LastEditors: HKH
 * @LastEditTime: 2024-09-13 16:21:42
 */
public class Animal1 {
    // 成员变量
    // 私有
    private String name; // 名字
    // 公开变量 显示初始化
    public int number = 10; // 数量
    // get set
  
    public Animal1() {
      System.out.println("Animal的无参构造器");
    };
  
    public Animal1(String name) {
      this(name, 0);// 放到第1行有效代码的位置
      System.out.println("Animal的单参构造器");
    }
  
    public Animal1(String name, int number) {
      System.out.println("Animal的全参构造器");
      this.name = name;
      this.number = number;
    };
  
    public void setName(String name) {
      this.name = name;
    }
  
    public String getName() {
      return this.name;
    }
  
    public void setNumber(int number) {
      this.number = number;
    }
  
    public int getNumber() {
      return this.number;
    }
  
    // sayHello
    public void sayHello() {
      System.out.println("自有:name:" + name);
      System.out.println("自有:number: " + number);
    }
  }